<%@ page import="com.wl.shixun5.*,java.util.*"%>
<%@ page import="com.wl.shixun5.dao.BookInfo_DAO" %>
<%@ page import="com.wl.shixun5.dao.OrderInfo_Orderdetail_DAO" %>
<%@ page import="com.wl.shixun5.info.BookInfo" %>
<%@ page import="com.wl.shixun5.info.OrderInfo" %>
<%@ page import="com.wl.shixun5.info.Orderdetail" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>2350300097 万朗</title>
</head>
<body>
<%
    String userId = (String)session.getAttribute("memberID");
    if (userId == null) {
        response.sendRedirect("index.jsp");
        return;
    }
    List<OrderInfo> orderList = OrderInfo_Orderdetail_DAO.findOrderByUserId(userId);
%>

<p align="center"><strong><font size="6">我的订单--小万网上书店</font></strong></p>

<div align="center">
<%
    if (orderList == null || orderList.size() == 0) {
%>
    <p><strong>您还没有任何订单！</strong></p>
    <p><a href="booklist.jsp">去选购图书</a></p>
<%
    } else {
        for(OrderInfo oi : orderList) {
%>
    <h3>订单号：<%=oi.getOrderId() %></h3>
    <table width="700" border="1" cellspacing="0" cellpadding="3">
        <tr>
            <td width="120"><strong>订单日期</strong></td>
            <td><%=oi.getOrderDate() %></td>
        </tr>
        <tr>
            <td><strong>收货人</strong></td>
            <td><%=oi.getReceiverName() %></td>
        </tr>
        <tr>
            <td><strong>收货地址</strong></td>
            <td><%=oi.getReceiverAdd() %></td>
        </tr>
        <tr>
            <td><strong>邮编</strong></td>
            <td><%=oi.getReceiverZip() %></td>
        </tr>
        <tr>
            <td><strong>订单总价</strong></td>
            <td><%=oi.getOrderPrice() %> 元</td>
        </tr>
        <tr>
            <td><strong>备注</strong></td>
            <td><%=oi.getOrderMemo() == null ? "无" : oi.getOrderMemo() %></td>
        </tr>
        <tr>
            <td><strong>订单状态</strong></td>
            <td><%=oi.getIsSale() == 0 ? "待处理" : "已发货" %></td>
        </tr>
    </table>
    
    <h4>订单详细：</h4>
    <table width="700" border="1" cellspacing="0" cellpadding="3">
        <tr>
            <th>ISBN</th>
            <th>书名</th>
            <th>单价</th>
            <th>数量</th>
            <th>小计</th>
        </tr>
<%
            List<Orderdetail> detailList = OrderInfo_Orderdetail_DAO.findOrderdetailByOrderId(oi.getOrderId());
            for(Orderdetail od : detailList) {
                BookInfo bi = BookInfo_DAO.findId(od.getBookId());
                float subtotal = bi.getPrice() * od.getBookCount();
%>
        <tr>
            <td align="center"><%=bi.getBookISBN() %></td>
            <td align="center"><%=bi.getBookName() %></td>
            <td align="center"><%=bi.getPrice() %></td>
            <td align="center"><%=od.getBookCount() %></td>
            <td align="center"><%=subtotal %></td>
        </tr>
<%
            }
%>
    </table>
    <hr>
<%
        }
    }
%>
</div>

<p align="center"><a href="booklist.jsp">继续购物</a>&nbsp;&nbsp;&nbsp;
    <a href="shoppingcart.jsp">查看购物车</a></p>

</body>
</html>
